
<!doctype html>
<html class="no-js" lang="">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Untitled Document</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="apple-touch-icon" href="apple-touch-icon.png">
    <!-- Place favicon.ico in the root directory -->

    <link rel="stylesheet" type="text/css" href="../../css/reset.css">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-default/index.css">
    
</head>

<body>
    <div class="loading">
        <span class="loadImg"></span>
    </div>
    <div id="app" class="prcAdd">
        <div class="info inputList">
            <p class="mt20"><span>奖品名称:</span><input type="text" class="t1 mel" name=""></p>
            <p><span>奖品图片:</span>
                <input type="file" id="imgTest" class="mel" accept=".gif,.jpg,.jpeg,.png" name="">
                <input type="text" class="t2 none" name=""> 
            </p>
            <p><span>奖品价格:</span><input type="num" class="t3 sol" name=""></p>
            <p><span>奖品几率:</span><input type="num" class="t4 sol" name=""></p>
            <p><button class="addClick">确定</button></p>
        </div>
    </div>
</body>

</html>
<script src="../../js/jquery.js"></script>
<script src="../../js/jquery.cookie.js"></script>
<script type="text/javascript" src="../../js/nicEdit.js"></script>
<script type="text/javascript">
    bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
</script>
<script type="text/javascript">

    $(function(){
        

        $('#imgTest').change(function(e){

            var reader = new FileReader();
            reader.onload = (function (file) {
                return function (e) {
                   $('.t2').val(this.result);
                };
            })(e.target.files[0]);
            reader.readAsDataURL(e.target.files[0]);
        })


        //提交数据
        $('.addClick').click(function(){
            var admintoken=$.cookie('admintoken');
            if(admintoken!=null){
                $('.loading').show();

                var name=$('.t1').val();
                var logo=$('.t2').val();
                var prices=$('.t3').val();
                var number=$('.t4').val();
                //var desc=nicEditors.findEditor('text').getContent();
                var data={
                            "prize_name":name,
                            "prize_price":prices,
                            "prize_image":logo,
                            "prize_rate":number
                        };
                $.ajax({
                    type: 'POST',
                    url:'http://www.math80.com/games/prizes',
                    headers:{Authorization:"Bearer "+admintoken},
                    data:data,
                    success:function(data){
                        $('.loading').hide();
                        alert('添加成功')
                        $('input').val('')
                    }
                })
            }
            

        })





    })

</script>
<!-- <script src="../../js/vue.min.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script type="text/javascript">
    new Vue({
      el: '#app',
      data: function() {
        return { 
            visible: false,
            value1: false,
        }
      }
    })
</script> -->
